package com.vista.questionnaire.domain.enumeration;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.vista.questionnaire.exception.BizException;
import com.vista.questionnaire.exception.ErrorDescriptor;

/**
 * The QuestionEnum enumeration.
 */
public enum QuestionEnum {
    RADIO("radio","单项选择题",0),
    CHECKBOX("checkbox","多项选择题",1),
    TEXT("text","填空题",2);

    private final String key;
    private final String value;
    private final long sort;

    QuestionEnum(String key, String value, long sort) {
        this.key = key;
        this.value = value;
        this.sort = sort;
    }

    @JsonCreator
    public static QuestionEnum getEnum(String name){
        for (QuestionEnum scope : values()) {
            if (scope.toString().toLowerCase().equals(name)) {
                return scope;
            }
        }
        throw new BizException(ErrorDescriptor.EunmPraseError);
    }
}
